﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CrankShaftAnalysisSystem
{
    public partial class FormManual : Form
    {
        FormIK220 formIK220;
        FormPanasonic formMotors;
        FormPLC formPLC;
        FormEastenGauge formEasten;
        FormMT2571 formMT2571;
        public FormManual()
        {
            InitializeComponent();
            formIK220 = new FormIK220();
            formMotors = new FormPanasonic();
            formPLC = new FormPLC();
            formEasten = new FormEastenGauge();
            formMT2571 = new FormMT2571();
        }

        private void btnIK220_Click(object sender, EventArgs e)
        {
            ShowSubForm(formIK220);
        }

        private void btnMotors_Click(object sender, EventArgs e)
        {
            ShowSubForm(formMotors);
        }

        private void btnPLC_Click(object sender, EventArgs e)
        {
            ShowSubForm(formPLC);
        }

        private void btnEasten_Click(object sender, EventArgs e)
        {
            ShowSubForm(formEasten);
        }

        private void btnMT2571_Click(object sender, EventArgs e)
        {
            ShowSubForm(formMT2571);
        }

        private void ShowSubForm(Form form)
        {
            form.Show();
            form.BringToFront();
        }

        public void StopAllTimers()
        {
            formIK220.tmUI.Stop();
            formMotors.tmLoop.Stop();
            formMT2571.tmLoop.Stop();
        }

        private void FormManual_Load(object sender, EventArgs e)
        {
            this.IsMdiContainer = true;
            formMotors.MdiParent = this;
            formEasten.MdiParent = this;
            formIK220.MdiParent = this;
            formMT2571.MdiParent = this;
            formPLC.MdiParent = this;
            formMotors.Parent = panelDevice;
            formEasten.Parent = panelDevice;
            formIK220.Parent = panelDevice;
            formMT2571.Parent = panelDevice;
            formPLC.Parent = panelDevice;
        }

        private void FormManual_FormClosing(object sender, FormClosingEventArgs e)
        {
            Hide();
            e.Cancel = true;
        }
    }
}
